import Vue from 'vue'
import Router from 'vue-router'
import GoodsList from '@/components/GoodsList'
import Hi from '@/components/hi'
import GoodsListImg from '@/components/GoodsListImg'
import GoodsListName from '@/components/GoodsListName'
import Title from '@/components/Title'
import Left from '@/components/Left'
import Right from '@/components/Right'
import Test from '@/views/Test'
import Content from '@/views/Content'
import Shouye from '@/views/Shouye'
import Redirect from '@/views/Redirect'
import Error from '@/components/Error'

Vue.use(Router) //全局使用 Router

export default new Router({
    mode:"history",
    routes:[
        {
            path:"/shouye/:userId/:userName",
            name:Shouye,
            component:Shouye,
            beforeEnter(to,from,next){
                console.log(to);
                console.log(from);
                // next({path:'/goParams'});
            }
        },{
            path:'/',
            name:'redirect',
            component:Redirect,
            // alias:"/content"//别名 与redirect重定向的区别是 url改变
        },{
            path:'/goHome',
            redirect:"/shouye/asd/this is a good job"
        },{
            path:"/goParams",
            redirect:"/"
        },{
            path:"/test",
            name:"Test",
            component:Test,
            children:[
                {
                    path:'/',
                    name:"Title",
                    components:{
                        title:Title,
                        left:Left,
                        right:Right
                    }
                },
                {
                    path:'btn1',
                    name:"btn1",
                    components:{
                        title:Title,
                        left:Left,
                        right:Right
                    }
                },
                {
                    path:'btn3',
                    name:"btn3",
                    components:{
                        title:Title,
                        left:Right,
                        right:Left
                    }
                },
                {
                    path:'btn2',
                    name:"btn2",
                    components:{
                        title:Left,
                        left:Right,
                        right:Title
                    }
                }
            ]
        },{
            path:"*",
            name:Error,
            component:Error
        }
        
    ]
})